﻿<Page
    x:Name="PageRoot"
    x:Class="IntegrationExample.FileSavePickerPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:IntegrationExample"
    xmlns:common="using:IntegrationExample.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:ExtensionType="FileOpenPicker">

    <Page.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="FilePickerResourceDictionary.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <CollectionViewSource x:Name="FilesViewSource" Source="{Binding Files}"/>
        </ResourceDictionary>
    </Page.Resources>
    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the command area
        * Row 1 contains the rest of the page layout
    -->
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="80"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        
        <!-- Command area -->
        <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="120,20,120,30">
            <TextBlock Text="Selected Contact:" Margin="3,-10,3,10" Style="{StaticResource SubheaderTextBlockStyle}"/>
            <ComboBox Margin="3,-3,3,0" ItemsSource="{Binding Contacts}" DisplayMemberPath="DisplayName" SelectedItem="{Binding SelectedContact, Mode=TwoWay}" SelectionChanged="HandleSelectedContactChanged"/>
        </StackPanel>

        <!-- Horizontal scrolling grid of files fills the remainder -->
        <GridView x:Name="FileGridView"
                  AutomationProperties.AutomationId="FileGridView"
                  AutomationProperties.Name="Files"
                  Grid.Row="0" Grid.RowSpan="2"
                  ItemsSource="{Binding Source={StaticResource FilesViewSource}}"
                  ItemTemplate="{StaticResource ExampleFileTemplate}"
                  SelectionMode="Single" 
                  SelectionChanged="HandleSelectedFileChanged"
                  Padding="116,76,116,20" 
                  Visibility="Visible" />
    </Grid>
</Page>
